<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
        <style>
			#loginForm{
				background-color: #ADD8E6;
				width: 200px;
				margin: 200px auto;
			}
		</style>	
	</head>
	<body>
		<div id="app">
			<div id="loginForm" v-if="!isLogin">
				<h1>用户登录</h1>
				<div>用户名:<input type="text" v-model="yhm" /></div>
					<div>密码:<input type="password" v-model="mm" /></div>
				<div><button v-on:click="login">登录</button></div>
			</div>
		
		<div v-else>
			{{yhm}}已登录
			<div><button @click="loginOut">登出</button></div>
		</div>
		</div>
		<script>			
			
			var app = Vue.createApp({
				data(){
					return {
						yhm:'',
						mm:'',
						isLogin:false
					}
				},
				methods:{
				    login:function(){
						console.log("login")
					if(this.yhm=="abc"&&this.mm=="123"){
						alert("登录成功")
						this.isLogin=true
				}
					else{
						alert("登录失败")
						
					}
				
				},
				loginOut:function(){
					this.isLogin=false;
				}
				}
			});
		
			var vm = app.mount("#app")
		</script>
	</body>
</html>
